<?php
require_once 'data_form'.EXT;

class Existing_coverage extends Data_form{
	
	function __construct()
	{
		parent::__construct();
		$this->data['title']	=	'Existing coverage';
		$this->data['module_title']	=	'Existing coverage';
		$this->load->helper('custom_string');
		
	}
	
	function index($ec_type = null, $id = null)
	{
		$this->load->model(array('existing_coverage_endowment_model','existing_coverage_term_model','existing_coverage_ilp_model','existing_coverage_wl_model'));
		$this->data['endowments']	=	$this->existing_coverage_endowment_model->get_many_by('customer_id',$_SESSION["customer"]["id"]);
		$this->data['terms']	=	$this->existing_coverage_term_model->get_many_by('customer_id',$_SESSION["customer"]["id"]);
		$this->data['ilps']	=	$this->existing_coverage_ilp_model->get_many_by('customer_id',$_SESSION["customer"]["id"]);
		$this->data['wls']	=	$this->existing_coverage_wl_model->get_many_by('customer_id',$_SESSION["customer"]["id"]);
		$param	=	'Endowment';
		$param	=	(isset($ec_type) ? $ec_type : $param);
		//case edit
		if($id)
		{
			switch($ec_type)
			{
				case	'Endowment':
					if(isset($_GET['act']) && $_GET['act'] == 'del')
					{
						$this->existing_coverage_endowment_model->delete($id);
						redirect(base_url().'existing_coverage/index');
						exit();
					}
					$row	=	$this->existing_coverage_endowment_model->get_by(array('customer_id' => $_SESSION["customer"]["id"],'id' => $id));
					$data	=	array(
						"customer_id"				=>	$row->customer_id,
						"policy_incepted"			=>	$row->policy_incepted,
						"policy_term"				=>	$row->policy_term,
						"sum_assured_death"			=>	$row->sum_assured_death,
						"sum_assured_disability"	=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"	=>	$row->sum_assured_critical_illness,
						"maturity_year"				=>	$row->maturity_year,
						"maturity_value"			=>	$row->maturity_value,
						"explanation"				=>	$row->explanation
					);
					$_SESSION["data"] = $data;
					break;
				case	'Term':
					
					if(isset($_GET['act']) && $_GET['act'] == 'del')
					{
						$this->existing_coverage_term_model->delete($id);
						redirect(base_url().'existing_coverage/index');
						exit();
					}
					
					$row	=	$this->existing_coverage_term_model->get_by(array('customer_id' => $_SESSION["customer"]["id"],'id' => $id));
					$data	=	array(
						"customer_id"				=>	$row->customer_id,
						"policy_incepted"			=>	$row->policy_incepted,
						"policy_term"				=>	$row->policy_term,
						"sum_assured_death"			=>	$row->sum_assured_death,
						"sum_assured_disability"	=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"	=>	$row->sum_assured_critical_illness,
						"decreasing"				=>	$row->decreasing,
						"explanation"				=>	$row->explanation
					);
					$_SESSION["data"] = $data;
					break;
				case	'WL':
					if(isset($_GET['act']) && $_GET['act'] == 'del')
					{
						$this->existing_coverage_wl_model->delete($id);
						redirect(base_url().'existing_coverage/index');
						exit();
					}
					$row	=	$this->existing_coverage_wl_model->get_by(array('customer_id' => $_SESSION["customer"]["id"],'id' => $id));
					$data	=	array(
						"customer_id"						=>	$row->customer_id,
						"policy_incepted"					=>	$row->policy_incepted,
						"policy_term"						=>	$row->policy_term,
						"sum_assured_death"					=>	$row->sum_assured_death,
						"sum_assured_disability"			=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"		=>	$row->sum_assured_critical_illness,
						"step_up_booster"					=>	$row->step_up_booster,
						"consider_cash_value_retirement"	=>	$row->consider_cash_value_retirement,
						"year_start"						=>	$row->year_start,
						"year_end"							=>	$row->year_end,
						"addictional_sum_assured_death"=>	$row->addictional_sum_assured_death,
						"addictional_sum_assured_disability"=>	$row->addictional_sum_assured_disability,
						"addictional_sum_assured_critical"	=>	$row->addictional_sum_assured_critical,
						"retirement_age"	=>	$row->retirement_age,
						"cva_retirement"	=>	$row->cva_retirement,
						"explanation"				=>	$row->explanation
					);
					
					$_SESSION["data"]	=	$data;
					break;
				case	'ILP':
					if(isset($_GET['act']) && $_GET['act'] == 'del')
					{
						$this->existing_coverage_ilp_model->delete($id);
						redirect(base_url().'existing_coverage/index');
						exit();
					}
					$row	=	$this->existing_coverage_ilp_model->get_by(array('customer_id' => $_SESSION["customer"]["id"],'id' => $id));
					$data	=	array(
						"customer_id"						=>	$row->customer_id,
						"policy_incepted"					=>	$row->policy_incepted,
						"policy_term"						=>	$row->policy_term,
						"sum_assured_death"					=>	$row->sum_assured_death,
						"sum_assured_disability"			=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"		=>	$row->sum_assured_critical_illness,
						"consider_cash_value_retirement"	=>	$row->consider_cash_value_retirement,
						"retirement_age"	=>	$row->retirement_age,
						"cva_retirement"	=>	$row->cva_retirement,
						"expected_annual_return"	=>	$row->expected_annual_return,
						"explanation"				=>	$row->explanation
					);
					$_SESSION["data"] = $data;
					break;
					
			}
			
			$this->data['row']	=	$data;
			$this->data['id']	=	$id;
		}
		
		//case after submit
		if($_SERVER['REQUEST_METHOD'] == 'POST' && (isset($_POST['btnAdd']) && ($_POST['btnAdd']=='Add' || $_POST['btnAdd']=='Edit') || isset($_POST['btnSubmit']) && $_POST['btnSubmit'] =='Submit'))
		{
			$param	=	$this->input->post('ec_type');
			
			switch($param)
			{
				case	'Endowment':
					$data_update	=	array(
							"customer_id"				=>	$_SESSION['customer']['id'],
							"policy_incepted"			=>	$this->input->post('textfield5'),
							"policy_term"				=>	$this->input->post('textfield'),
							"sum_assured_death"			=>	$this->input->post('textfield2a'),
							"sum_assured_disability"	=>	$this->input->post('textfield2b'),
							"sum_assured_critical_illness"	=>	$this->input->post('textfield2c'),
							"maturity_year"				=>	intval($this->input->post('textfield5'))+intval($this->input->post('textfield')),
							"maturity_value"			=>	$this->input->post('textfield3b')
					);
					
					if(isset($_POST['Explanation']))
					{
						$data_update["explanation"]	=	$_POST["Explanation"];
					}
					
					//print_r($data_update);die;
					
					if($id){
						$this->existing_coverage_endowment_model->update($id,$data_update);
					}//update with id
					else{
						$this->existing_coverage_endowment_model->insert($data_update);
					}//insert new row	
					break;//case Endowment
				case	'Term':
					$data_update	=	array(
							"customer_id"				=>	$_SESSION['customer']['id'],
							"policy_incepted"			=>	$this->input->post('textfield5'),
							"policy_term"				=>	$this->input->post('textfield'),
							"sum_assured_death"			=>	$this->input->post('textfield22a'),
							"sum_assured_disability"	=>	$this->input->post('textfield22b'),
							"sum_assured_critical_illness"	=>	$this->input->post('textfield22c'),
							"decreasing"	=>	($this->input->post('decreasing') ? $this->input->post('decreasing') : 0)
					);
					
					
					if(isset($_POST['Explanation']))
					{
						$data_update["explanation"]	=	$_POST["Explanation"];
					}
					
					if($id){
						$this->existing_coverage_term_model->update($id,$data_update);
						//echo "adasd";print_r($data_update);die($this->input->post('decreasing').'asasa');	
					}//update with id
					else{
						$this->existing_coverage_term_model->insert($data_update);
					}//insert new row	
					break;//case Endowment
				case	'ILP':
					$data_update	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"retirement_age"	=>	$_POST['retirement_age'],
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0),
							"expected_annual_return"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["expected_annual_return"] : 0)
						);
					
					if(isset($_POST['Explanation']))
					{
						$data_update["explanation"]	=	$_POST["Explanation"];
					}
					
					if($id){
						$this->existing_coverage_ilp_model->update($id,$data_update);
					}
					else{
						$this->existing_coverage_ilp_model->insert($data_update);
					}
					break;
				case	'WL':
					$data_update	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"step_up_booster"					=>	(isset($_POST["step_booster"]) ? 1 : 0),
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"year_start"						=>	(isset($_POST["step_booster"]) ? $_POST["year_start"] : 0),
							"year_end"							=>	(isset($_POST["step_booster"]) ? $_POST["year_end"] : 0),
							"addictional_sum_assured_death"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_death"] : 0),
							"addictional_sum_assured_disability"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_disability"] : 0),
							"addictional_sum_assured_critical"	=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_critical"] : 0),
							"retirement_age"	=>	$_POST['retirement_age'],
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0)
					);
					
					if(isset($_POST['Explanation']))
					{
						$data_update["explanation"]	=	$_POST["Explanation"];
					}
					
					if($id){
						$this->existing_coverage_wl_model->update($id,$data_update);
					}
					else{
						$this->existing_coverage_wl_model->insert($data_update);
					}
					break;	
			}
			
			redirect(base_url().'existing_coverage/');
		}//End Add or Edit
		
		
		if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['btnCalculate']) && $_POST['btnCalculate']=='Calculate')
		{
			$param	=	$this->input->post('ec_type');
			switch($param)
			{
				case	'Endowment':
					$data_update	=	array(
							"customer_id"				=>	$_SESSION['customer']['id'],
							"policy_incepted"			=>	$this->input->post('textfield5'),
							"policy_term"				=>	$this->input->post('textfield'),
							"sum_assured_death"			=>	$this->input->post('textfield2a'),
							"sum_assured_disability"	=>	$this->input->post('textfield2b'),
							"sum_assured_critical_illness"	=>	$this->input->post('textfield2c'),
							"maturity_year"				=>	intval($this->input->post('textfield5'))+intval($this->input->post('textfield')),
							"maturity_value"			=>	$this->input->post('textfield3b')
					);
					break;//case Endowment
				case	'Term':
					$data_update	=	array(
							"customer_id"				=>	$_SESSION['customer']['id'],
							"policy_incepted"			=>	$this->input->post('textfield5'),
							"policy_term"				=>	$this->input->post('textfield'),
							"sum_assured_death"			=>	$this->input->post('textfield22a'),
							"sum_assured_disability"	=>	$this->input->post('textfield22b'),
							"sum_assured_critical_illness"	=>	$this->input->post('textfield22c'),
							"decreasing"	=> ($this->input->post('decreasing') ? $this->input->post('decreasing') : 0)
					);
					break;//case Endowment
				case	'ILP':
					$data_update	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"retirement_age"	=>	$_POST['retirement_age'],
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0),
							"expected_annual_return"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["expected_annual_return"] : 0)
						);
					break;
				case	'WL':
					$data_update	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"step_up_booster"					=>	(isset($_POST["step_booster"]) ? 1 : 0),
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"year_start"						=>	(isset($_POST["step_booster"]) ? $_POST["year_start"] : 0),
							"year_end"							=>	(isset($_POST["step_booster"]) ? $_POST["year_end"] : 0),
							"addictional_sum_assured_death"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_death"] : 0),
							"addictional_sum_assured_disability"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_disability"] : 0),
							"addictional_sum_assured_critical"	=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_critical"] : 0),
							"retirement_age"	=>	$_POST['retirement_age'],
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0)
					);
					break;	
			}
			$this->data['row']	=	$data_update;
			//redirect(base_url().'existing_coverage/index/'.$param.($id ? '/'.$id : ''));
		}//End case Calculate
		
		$this->data['param']	=	$param;
		$this->load->view("existing_coverage/index", $this->data);
	}
	
	function index_old($param = NULL)
	{
		$this->load->model(array('existing_coverage_endowment_model','existing_coverage_term_model'));
		$this->data['endowments']	=	$this->existing_coverage_endowment_model->get_many_by('customer_id',$_SESSION["customer"]["id"]);
		$data = array();
		if($param){
			$this->load->model('existing_coverage_'.strtolower($param).'_model');
		}
		$row	=	array();
		$submit	=	($this->input->post("submit") == "0" ? false : true);
		switch ($param){
			case 'Endowment':
				
				$row	=	$this->existing_coverage_endowment_model->get_by('customer_id',$_SESSION["customer"]["id"]);
				//parse data from row to $data
				if($_SERVER['REQUEST_METHOD'] == 'GET' && $row)
				{
					$data	=	array(
						"customer_id"				=>	$row->customer_id,
						"policy_incepted"			=>	$row->policy_incepted,
						"policy_term"				=>	$row->policy_term,
						"sum_assured_death"			=>	$row->sum_assured_death,
						"sum_assured_disability"	=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"	=>	$row->sum_assured_critical_illness,
						"maturity_year"				=>	$row->maturity_year,
						"maturity_value"			=>	$row->maturity_value
					);
					$_SESSION["data"] = $data;
					//echo "First init: ";
					//print_r($data);
				}
				
				if($_SERVER['REQUEST_METHOD'] == 'POST'){
					if (!$submit)
					{
						$data	=	array(
							"customer_id"				=>	$_SESSION["customer"]["id"],
							"policy_incepted"			=>	$_POST["textfield5"],
							"policy_term"				=>	$_POST["textfield"],
							"sum_assured_death"			=>	$_POST["textfield2a"],
							"sum_assured_disability"	=>	$_POST["textfield2b"],
							"sum_assured_critical_illness"	=>	$_POST["textfield2c"],
							"maturity_year"				=>	$_POST["textfield3a"],
							"maturity_value"			=>	$_POST["textfield3b"]
						);
						$_SESSION["data"] = $data;
						//echo "Assign data from form to session: ";
						//print_r($data);
					}
					else
					{
						$data = $_SESSION["data"];
						//echo "Get data from form to session: ";
						//print_r($data);
						if($row){
							$this->existing_coverage_endowment_model->update($row->id,$data);
						}
						else
						{
							$this->existing_coverage_endowment_model->insert($data);
						}
						//$row	=	$this->existing_coverage_endowment_model->get_by('customer_id',$_SESSION["customer"]["id"]);
					}
				}
				break;
			case	'Term':
				$row	=	$this->existing_coverage_term_model->get_by('customer_id',$_SESSION["customer"]["id"]);
				if($_SERVER['REQUEST_METHOD'] == 'GET' && $row)
				{
					$data	=	array(
						"customer_id"				=>	$row->customer_id,
						"policy_incepted"			=>	$row->policy_incepted,
						"policy_term"				=>	$row->policy_term,
						"sum_assured_death"			=>	$row->sum_assured_death,
						"sum_assured_disability"	=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"	=>	$row->sum_assured_critical_illness,
						"decreasing"				=>	$row->decreasing
					);
					$_SESSION["data"] = $data;
				}
				
				if($_SERVER['REQUEST_METHOD'] == 'POST')
				{
					//	print_r($_POST);die;
					if(!$submit){
						$data	=	array(
							"customer_id"				=>	$_SESSION["customer"]["id"],
							"policy_incepted"			=>	$_POST["textfield5"],
							"policy_term"				=>	$_POST["textfield"],
							"sum_assured_death"			=>	$_POST["textfield22a"],
							"sum_assured_disability"	=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"	=>	$_POST["textfield22c"],
							"decreasing"				=>	(isset($_POST["c1"]) ? 1 : 0)
						);
						$_SESSION["data"]	=	$data;
					}
					else{
						
						$data	=	$_SESSION["data"];
						if($row){
							$this->existing_coverage_term_model->update($row->id,$data);
						}
						else
						{
							$this->existing_coverage_term_model->insert($data);
						}
						//$row	=	$this->existing_coverage_term_model->get_by('customer_id',$_SESSION["customer"]["id"]);
					}
				}
				break;//end case $param	=	Term
				
			case	'WL':
				$row	=	$this->existing_coverage_wl_model->get_by('customer_id',$_SESSION["customer"]["id"]);
				
				if($_SERVER['REQUEST_METHOD'] == 'GET' && $row)
				{
					$data	=	array(
						"customer_id"						=>	$row->customer_id,
						"policy_incepted"					=>	$row->policy_incepted,
						"policy_term"						=>	$row->policy_term,
						"sum_assured_death"					=>	$row->sum_assured_death,
						"sum_assured_disability"			=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"		=>	$row->sum_assured_critical_illness,
						"step_up_booster"					=>	$row->step_up_booster,
						"consider_cash_value_retirement"	=>	$row->consider_cash_value_retirement,
						"year_start"						=>	$row->year_start,
						"year_end"							=>	$row->year_end,
						"addictional_sum_assured_death"=>	$row->addictional_sum_assured_death,
						"addictional_sum_assured_disability"=>	$row->addictional_sum_assured_disability,
						"addictional_sum_assured_critical"	=>	$row->addictional_sum_assured_critical,
						"retirement_age"	=>	$row->retirement_age,
						"cva_retirement"	=>	$row->cva_retirement
					);
					
					$_SESSION["data"]	=	$data;
				}
				
				if($_SERVER['REQUEST_METHOD'] == 'POST')
				{
					//print_r($_POST);die;
					if(!$submit)
					{
						$data	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"step_up_booster"					=>	(isset($_POST["step_booster"]) ? 1 : 0),
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"year_start"						=>	(isset($_POST["step_booster"]) ? $_POST["year_start"] : 0),
							"year_end"							=>	(isset($_POST["step_booster"]) ? $_POST["year_end"] : 0),
							"addictional_sum_assured_death"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_death"] : 0),
							"addictional_sum_assured_disability"=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_disability"] : 0),
							"addictional_sum_assured_critical"	=>	(isset($_POST["step_booster"]) ? $_POST["addictional_sum_assured_critical"] : 0),
							"retirement_age"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["retirement_age"] : 0),
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0)
						);
						$_SESSION["data"]	=	$data;
					}
					else 
					{
						$data	=	$_SESSION["data"];
						if($row){
							$this->existing_coverage_wl_model->update($row->id,$data);
						}
						else
						{
							$this->existing_coverage_wl_model->insert($data);
						}
					}
					//$row	=	$this->existing_coverage_wl_model->get_by('customer_id',$_SESSION["customer"]["id"]);
				}
				break;//end case $param	= WL
				
			case	'ILP':
				$row	=	$this->existing_coverage_ilp_model->get_by('customer_id',$_SESSION["customer"]["id"]);
				
				if($_SERVER['REQUEST_METHOD'] == 'GET' && $row)
				{
					$data	=	array(
						"customer_id"						=>	$row->customer_id,
						"policy_incepted"					=>	$row->policy_incepted,
						"policy_term"						=>	$row->policy_term,
						"sum_assured_death"					=>	$row->sum_assured_death,
						"sum_assured_disability"			=>	$row->sum_assured_disability,
						"sum_assured_critical_illness"		=>	$row->sum_assured_critical_illness,
						"consider_cash_value_retirement"	=>	$row->consider_cash_value_retirement,
						"retirement_age"	=>	$row->retirement_age,
						"cva_retirement"	=>	$row->cva_retirement,
						"expected_annual_return"	=>	$row->expected_annual_return
					);
					
					$_SESSION["data"]	=	$data;
				}
				
				if($_SERVER['REQUEST_METHOD'] == 'POST')
				{
						//print_r($_POST);die;
					if(!$submit)
					{
						$data	=	array(
							"customer_id"						=>	$_SESSION["customer"]["id"],
							"policy_incepted"					=>	$_POST["textfield5"],
							"policy_term"						=>	$_POST["textfield"],
							"sum_assured_death"					=>	$_POST["textfield22a"],
							"sum_assured_disability"			=>	$_POST["textfield22b"],
							"sum_assured_critical_illness"		=>	$_POST["textfield22c"],
							"consider_cash_value_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? 1 : 0),
							"retirement_age"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["retirement_age"] : 0),
							"cva_retirement"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["cva_retirement"] : 0),
							"expected_annual_return"	=>	(isset($_POST["consider_cash_value_retirement"]) ? $_POST["expected_annual_return"] : 0)
						);
						$_SESSION["data"]	=	$data;
					}
					else
					{
						$data	=	$_SESSION["data"];
						if($row){
							$this->existing_coverage_ilp_model->update($row->id,$data);
						}
						else
						{
							$this->existing_coverage_ilp_model->insert($data);
						}
						//$row	=	$this->existing_coverage_ilp_model->get_by('customer_id',$_SESSION["customer"]["id"]);
					}
				}
				break;//end case $param = ILP
		}
		
		$this->data['row']	=	$data;
		$this->data['param']	=	$param;
		
		$this->load->view("existing_coverage/index", $this->data);
	}
	

}